﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Benefit.Models.ServerData;
namespace Benefit.Interface.ServerData
{
    public interface IT_TradeDetail_History
    {
       

        /// <summary>
        /// 查询结算后的成交明细情况
        /// </summary>
        /// <param name="accountid"></param>
        /// <param name="pdate"></param>
        /// <returns></returns>
        System.Collections.Generic.List<T_TradeDetail_History> GetInfo(string pdate);

        /// <summary>
        /// 查询某天最大结算编号的成交明细
        /// </summary>
        /// <param name="settlementid">结算编号</param>
        /// <param name="pdate">日期</param>
        /// <returns></returns>
        System.Collections.Generic.List<T_TradeDetail_History> GetTradeDetailHistory(int settlementid, string pdate);

        /// <summary>
        /// 每天都需要执行的把Server中的数据导入到分析系统中的方法
        /// </summary>
        /// <param name="pdate">日期</param>
        void CopyServerTradeDetailHistoryDataIntoBenefit(string pdate);


        /// <summary>
        /// 删除某日的所有持仓明细记录
        /// </summary>
        /// <param name="pdate"></param>
        void DeleteDayTradeDetailHistoryFromBenefit(string pdate);




        #region 合约统计
        /// <summary>
        /// 获取某日一个账户所交易的不同合约
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="accountid"></param>
        /// <returns></returns>
        List<string> GetAccountDayInstrument(string pdate, int serverAccountid);
        /// <summary>
        /// 得到查询日的交易次数(如果第一天有一手持仓，第二天平掉，那手平仓将视为第一天的交易次数)
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetInstrumentTradeCountOnDay(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取某日交易笔数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayInstrumentBillCount(string pdate, int serverAccountId, string instrumentid, string direction);
        /// <summary>
        /// 获取某日总亏损
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayInstrumentAllLose(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取某日总盈利
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayInstrumentAllWin(string pdate, int serverAccountId, string instrument, string direction);



        /// <summary>
        /// 获取当天盈利次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayInstrumentWinCount(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取当天平单次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayInstrumentPingCount(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取当天亏损次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayInstrumentLoseCount(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取最大回撤
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="serverAccountId"></param>
        /// <returns></returns>
        double GetInstrumentMaxReturn(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取当天手续费
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayInstrumentCommission(string pdate, int serverAccountId, string instrument, string direction);
        /// <summary>
        /// 获取当天平仓盈亏
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayInstrumentCloseProfit(string pdate, int serverAccountId, string instrument, string direction);



        #endregion

        #region 品种统计
        /// <summary>
        /// 获取某日一个账户所交易的不同品种
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="accountid"></param>
        /// <returns></returns>
        List<string> GetAccountDayProduct(string pdate, int serverAccountid);
        /// <summary>
        /// 获取某日交易笔数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayProductBillCount(string pdate, int serverAccountId, string productid, string direction);
        /// <summary>
        /// 获取某日总亏损
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayProductAllLose(string pdate, int serverAccountId, string product, string direction);
        /// <summary>
        /// 获取某日总盈利
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayProductAllWin(string pdate, int serverAccountId, string product, string direction);
        /// <summary>
        /// 获取当天平单次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayProductPingCount(string pdate, int serverAccountId, string product, string direction);
        /// <summary>
        /// 获取当天亏损次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayProductLoseCount(string pdate, int serverAccountId, string product, string direction);
        /// <summary>
        /// 获取最大回撤
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="serverAccountId"></param>
        /// <returns></returns>
        double GetProductMaxReturn(string pdate, int serverAccountId, string product, string direction);


        /// <summary>
        /// 平均单笔盈利
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="serverAccountId"></param>
        /// <returns></returns>
        double GetProductAvgBillBenefit(string pdate, int serverAccountId, string product, string direction);

        /// <summary>
        /// 获取当天手续费
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayProductCommission(string pdate, int serverAccountId, string product, string direction);
        /// <summary>
        /// 获取当天平仓盈亏
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayProductCloseProfit(string pdate, int serverAccountId, string product, string direction);
        /// <summary>
        /// 获取当天盈利次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayProductWinCount(string pdate, int serverAccountId, string product, string direction);


        #endregion

        #region 账户统计
        /// <summary>
        /// 得到查询日的交易次数(如果第一天有一手持仓，第二天平掉，那手平仓将视为第一天的交易次数)
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetTradeCountOnDay(string pdate, int serverAccountId);
        /// <summary>
        /// 获取某日总亏损
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayAllLose(string pdate, int serverAccountId);
        /// <summary>
        /// 获取某日总盈利
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayAllWin(string pdate, int serverAccountId);

        /// <summary>
        /// 获取当天盈利次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayWinCount(string pdate, int serverAccountId);

        /// <summary>
        /// 获取最大回撤
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="serverAccountId"></param>
        /// <returns></returns>
        double GetMaxReturn(string pdate, int serverAccountId);


        /// <summary>
        /// 获取当天平单次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayPingCount(string pdate, int serverAccountId);


        /// <summary>
        /// 获取当天亏损次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayLoseCount(string pdate, int serverAccountId);
        /// <summary>
        /// 获取某日交易笔数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayBillCount(string pdate, int serverAccountId);
        /// <summary>
        /// 获取某日总的开仓保证金(由于保证金比较难算，暂时只用平仓盈亏总和来算)
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="serverAccountId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        double GetAllOpenMoney(string pdate, int serverAccountId);

        #endregion



        #region 分时统计


        /// <summary>
        /// 得到查询日分时的交易次数(如果第一天有一手持仓，第二天平掉，那手平仓将视为第一天的交易次数)
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetStateTradeCountOnDay(string pdate, int serverAccountId, int state);

        /// <summary>
        /// 获取某日分时交易笔数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetStateDayBillCount(string pdate, int serverAccountId, int state);
        /// <summary>
        /// 获取某日分时总亏损
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetStateDayAllLose(string pdate, int serverAccountId, int state);
        /// <summary>
        /// 获取某日分时总盈利
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetStateDayAllWin(string pdate, int serverAccountId, int state);

        /// <summary>
        /// 获取当天分时盈利次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetStateDayWinCount(string pdate, int serverAccountId, int state);

        /// <summary>
        /// 获取当天分时平仓盈亏
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayStateCloseProfit(string pdate, int serverAccountId, int state);

        /// <summary>
        /// 获取当天分时手续费
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayStateCommission(string pdate, int serverAccountId, int state);

        /// <summary>
        /// 获取当天分时亏损次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayStateLoseCount(string pdate, int serverAccountId, int state);

        /// <summary>
        /// 获取分时保证金
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayStateMargin(string pdate, int serverAccountId, int state);


        #endregion

        /// <summary>
        /// 获取账户平均持仓时间
        /// </summary>
        /// <param name="pdate"></param>
        /// <param name="serverAccountId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        double GetAccountAvgPostionTime(string pdate, int serverAccountId, int accountId, int tradeHistoryId);

        #region 经纪公司收益



        /// <summary>
        /// 得到查询日经纪公司的交易次数(如果第一天有一手持仓，第二天平掉，那手平仓将视为第一天的交易次数)
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetBrokerTradeCountOnDay(string pdate, string brokerid);

        /// <summary>
        /// 获取某日经纪公司交易笔数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetBrokerDayBillCount(string pdate, string brokerid);
        /// <summary>
        /// 获取某日经纪公司总亏损
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetBrokerDayAllLose(string pdate, string brokerid);
        /// <summary>
        /// 获取某日经纪公司总盈利
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetBrokerDayAllWin(string pdate, string brokerid);

        /// <summary>
        /// 获取当天经纪公司盈利次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetBrokerDayWinCount(string pdate, string brokerid);

        /// <summary>
        /// 获取当天经纪公司平仓盈亏
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayBrokerCloseProfit(string pdate, string brokerid);

        /// <summary>
        /// 获取当天经纪公司手续费
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        double GetDayBrokerCommission(string pdate, string brokerid);

        /// <summary>
        /// 获取当天经纪公司亏损次数
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayBrokerLoseCount(string pdate, string brokerid);

        /// <summary>
        /// 获取经纪公司保证金
        /// </summary>
        /// <param name="pdate"></param>
        /// <returns></returns>
        int GetDayBrokerMargin(string pdate, string brokerid);




        #endregion
    }
}